package com.t4l.server.rpcservices;

import javax.servlet.annotation.WebServlet;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.t4l.client.services.login.signup.SignupService;
import com.t4l.server.entity.T4LUser;
import com.t4l.server.persistence.PersistenceUtil;
import com.t4l.shared.exceptions.T4LException;

@SuppressWarnings("serial")
@WebServlet(urlPatterns = "/t4l/signup")
public class SignupServiceImpl extends RemoteServiceServlet implements
		SignupService {

	public SignupServiceImpl() {
		super();
	}

	@Override
	public String signup(String name, String lastName, String email,
			String password) throws T4LException {
		T4LUser user = new T4LUser();
		user.setName(name);
		user.setLastName(lastName);
		user.setEmail(email);
		user.setPassword(password);
		PersistenceUtil.saveEntity(user);
		return user.toJson().toString();
	}
}
